<template>
  <div>
    <to-search></to-search>
    <!-- 3.遍历数据  -->
    <router-link
      :to="{ name: '详情', params: { id: item.id } }"
      v-for="item in arr"
      :key="item.id"
    >
      <img :src="$pre + item.img" alt="" />
      <div>name:{{ item.goodsname }}</div>
      <div>price:{{ item.price | filterPrice }}</div>
    </router-link>
    <!-- 暂无数据  -->
    <div v-if="arr.length == 0">暂无数据</div>
  </div>
</template>

<script>
import axios from "axios";
export default {
data(){
    return{
        arr:[],
    };
},
mounted(){
    //请求数据
    axios({
          url: "/api/getgoodlist",
      method: "get",
      params: {
        cateid: this.$route.query.id,
        type: 1,
      },
    }).then((res) => {
      // console.log(res);
      this.arr = res.data.list.goodData ? res.data.list.goodData : [];
    })
}
}
</script>

<style lang="less" scoped>
@import "../../less/index.less";

</style>